// business服务
define('businessServers', ['angular','jquery'], function (angular,$) {
    var module = angular.module('servers');
    module.factory('businessServers', ['$http','Urlconfig',function($http,Urlconfig) { 
        var obj = {
            //添加一条商机/business/add
            addBusiness: function (info) {
                return $http({
                    method  : 'post',
                    url: 'http://'+Urlconfig.apiUrl+':8888/api/business/add',
                    data:$.param(info),
                    headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
                }).then(function (response) {
                    return response.data;
                });
            },
            //批量添加商机/business/add
            addMultitermBusiness: function (info,companyid) {
                return $http({
                    method  : 'post',
                    url: 'http://'+Urlconfig.apiUrl+':8888/api/business/addMultiterm',
                    data:$.param({"dataStr":info,"companyid":companyid}),
                    headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
                }).then(function (response) {
                    return response.data;
                });
            },
            // 获取商机列表
            getBusinessList:function(info){
                return $http({
                    method  : 'post',
                    url: 'http://'+Urlconfig.apiUrl+':8888/api/business/getBusinessList',
                    data:$.param(info),
                    headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
                }).then(function (response) {
                    return response.data;
                });
            },
            // 获取一个商机
            getBusinessById:function(id){
                return $http({
                    method  : 'post',
                    url: 'http://'+Urlconfig.apiUrl+':8888/api/business/getBusinessById',
                    data:$.param({id:id}),
                    headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
                }).then(function (response) {
                    return response.data;
                });
            },
            // 获取销售排行
            getSalesRank:function(info){
                return $http({
                    method  : 'post',
                    url: 'http://'+Urlconfig.apiUrl+':8888/api/business/getSalesRank',
                    data:$.param(info),
                    headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
                }).then(function (response) {
                    return response.data;
                });
            },
            setMultitermBusiness:function(arr){
                return $http({
                    method  : 'POST',
                    url: 'http://'+Urlconfig.apiUrl+':8888/api/business/setMultiterm',
                    data:$.param({jsonStr:angular.toJson(arr)}),
                    headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
                }).then(function (response) {
                    return response.data;
                });
            }
        };
        return obj;
    }]);
});